#pragma once

#include <Windows.h>
#include <gl\GL.h>
#include <gl\GLU.h>
#include <vector>
#include <map>
#include "Mesh.h"
using std::map;
using std::vector;
using std::string;

class ModelLoader
{
private:
	enum FaceType
	{
		FACE_NOT_SUPPORTED = 0,
		TRIANGLE_WITH_NO_UV_NO_NORM,
		TRIANGLE_WITH_UV_NO_NORM,
		TRIANGLE_WITH_NORM_NO_UV,
		TRIANGLE_WITH_UV_NORM,
		QUAD_WITH_NO_UV_NO_NORM,
		QUAD_WITH_UV_NO_NORM,
		QUAD_WITH_NORM_NO_UV,
		QUAD_WITH_UV_NORM		
	};

	static ModelLoader * instance;
	ModelLoader(ModelLoader const &){};
	ModelLoader& operator=(ModelLoader const &){};
	ModelLoader();
	void extractMaterials(vector<string>& lines, map<string, GLuint>& materials, string filePath);
	void processMaterials(map<string, GLuint>& materials, string fileName, string filePath);
	bool startsWith(string starter, string text);
	FaceType getMeshType(string str);

public:
	~ModelLoader(void);
	static ModelLoader * get();
	GLuint loadTexture(const char * fileName);
	Mesh * loadModel(const char * fileName);
};
